﻿using SelfMadeMillionaire.Web.Infrastructure.ViewModels.ContactUs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Recaptcha;
using SelfMadeMillionaire.Core.Services;
using SelfMadeMillionaire.Core.Enums;
using SelfMadeMillionaire.Web.Infrastructure.ViewModels.Home;
using SelfMadeMillionaire.Core.Specifications.Publications;

namespace SelfMadeMillionaire.Web.Infrastructure.Controllers
{
	public class SelfmadeMillionaireController : BaseController
	{
		readonly IPublicationService _publicationService;
		readonly ISubscriberService _subscriberService;

        public SelfmadeMillionaireController(IPublicationService publicationService, ISubscriberService subscriberService)
		{
			_publicationService = publicationService;
			_subscriberService = subscriberService;
		}

		[HttpGet]
		public ActionResult Index()
		{
            Session[Constants.PRODUCT_TYPE_SESSION_KEY] = ProductType.SelfMadeMillionaire;

			var model = new HomeViewModel
			{
                Publications = _publicationService.GetList(new PublicationsListSpecification(null, null, ProductType.SelfMadeMillionaire, null, false, GetMinAccessLevel())).Where(x => x.IsShowOnHomePage).ToList()
			};

			return View(model);
		}

		private SubscriptionType GetMinAccessLevel()
		{
			var minAccessLevel = SubscriptionType.Platinum;
			//if (Request.IsAuthenticated)
			//	minAccessLevel = _subscriberService.GetMinAccessLevel(User.Identity.Name);

			return minAccessLevel;
		}
	}
}
